home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / qtools0.2-src.lha / src / libqtools / crc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-13  |  698 b   |  28 lines

  1. #ifndef    CRC_H
  2. #define    CRC_H
  3.  
  4. #define CRC_INIT_VALUE    0xffff
  5. #define CRC_XOR_VALUE    0x0000
  6.  
  7. extern unsigned short int crctable[256];
  8.  
  9. static void CRC_Init(unsigned short int *crcvalue);
  10. static void CRC_ProcessByte(unsigned short int *crcvalue, unsigned char data);
  11. static unsigned short int CRC_Value(unsigned short int crcvalue);
  12.  
  13. static inline void CRC_Init(unsigned short int *crcvalue)
  14. {
  15.   *crcvalue = CRC_INIT_VALUE;
  16. }
  17.  
  18. static inline void CRC_ProcessByte(unsigned short int *crcvalue, unsigned char data)
  19. {
  20.   *crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
  21. }
  22.  
  23. static inline unsigned short int CRC_Value(unsigned short int crcvalue)
  24. {
  25.   return crcvalue ^ CRC_XOR_VALUE;
  26. }
  27. #endif
  28.